﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Com.Rivyer.Web.ip
{
    public partial class ipstatistics : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string vlan = "";
            string title = "";
            for (int i = 1; i <= 19; i++)
            {
                if (i==4 || i==14)
                {
                    continue;
                }
                if (i == 1)
                {
                    vlan = "";
                    title = "总数";
                }
                else
                { 
                    vlan = i.ToString();
                    title = "Vlan" + i;
                }
                TableRow tr = new TableRow();

                TableCell titr = new TableCell();
                titr.Controls.Add(new LiteralControl(title));
                tr.Cells.Add(titr);

                TableCell tc = new TableCell();
                string all = new BLL.ipaddressBll().GetIP(vlan);
                tc.Controls.Add(new LiteralControl(all));
                tr.Cells.Add(tc);

                TableCell tc1 = new TableCell();
                string used = new BLL.ipaddressBll().GetUsedIP(vlan);
                tc1.Controls.Add(new LiteralControl(used));
                tr.Cells.Add(tc1);

                TableCell tc2 = new TableCell();
                Label lc = new Label();
                double leverage = int.Parse(used) / 1.0 / int.Parse(all) * 100;
                leverage = Math.Round(leverage / 100, 4) * 100;
                lc.Text = leverage.ToString() + "%";
                lc.CssClass = string.Format("level{0}", Maticsoft.Common.rivutils.getLeverageLevel(leverage/100));
                tc2.Controls.Add(lc);
                tr.Cells.Add(tc2);

                ipstatisc.Rows.Add(tr);
                
            }
            for (int i = 101; i <= 111; i++)
            {
                vlan = i.ToString();
                title = "Vlan" + i;
                if (i==102||i==103)
                {
                    continue;
                }
                TableRow tr = new TableRow();

                TableCell titr = new TableCell();
                titr.Controls.Add(new LiteralControl(title));
                tr.Cells.Add(titr);

                TableCell tc = new TableCell();
                string all = new BLL.ipaddressBll().GetIP(vlan);
                tc.Controls.Add(new LiteralControl(all));
                tr.Cells.Add(tc);

                TableCell tc1 = new TableCell();
                string used = new BLL.ipaddressBll().GetUsedIP(vlan);
                tc1.Controls.Add(new LiteralControl(used));
                tr.Cells.Add(tc1);

                TableCell tc2 = new TableCell();
                Label lc = new Label();
                double leverage = int.Parse(used) / 1.0 / int.Parse(all) * 100;
                leverage = Math.Round(leverage / 100, 4) * 100;
                lc.Text = leverage.ToString() + "%";
                lc.CssClass = string.Format("level{0}", Maticsoft.Common.rivutils.getLeverageLevel(leverage / 100));
                tc2.Controls.Add(lc);
                tr.Cells.Add(tc2);

                ipstatisc.Rows.Add(tr);
                
            }


            /*
            ASPxLabel1.Text = new BLL.ipaddressBll().GetIP("");
            ASPxLabel2.Text = new BLL.ipaddressBll().GetUsedIP("");
            {
                ASPxLabel3.Text = (int.Parse(ASPxLabel2.Text) / 1.0 / int.Parse(ASPxLabel1.Text) * 100).ToString() + "%";
                ASPxLabel3.CssClass = string.Format("level{0}", Maticsoft.Common.rivutils.getLeverageLevel(double.Parse(ASPxLabel3.Text.Remove(ASPxLabel3.Text.LastIndexOf('%'), 1)) / 100));
            }
            */

        }


    }
}